const app = getApp();
const http = require('../../utils/http.js')
Page({

    /**
     * 页面的初始数据
     */
    data: {
        authUrl: null
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({
            customer: app.globalData.customer
        })
        let miniAppid = wx.getAccountInfoSync().miniProgram.appId
        //console.log(miniAppid)
        let miniOpenid = wx.getStorageSync('userInfo').miniOpenid
        this.setData({
            authUrl: http.baseURL + '/api/user/webAuthorize?miniAppid=' + miniAppid + '&miniOpenid=' + miniOpenid
        })
    },

    authSuccess() {
        http.get("/api/user/isWebAuthorize").then(res => {
            app.globalData.userInfo = res.data
            wx.setStorageSync('userInfo', app.globalData.userInfo)
            if (res.code == 200) {
                wx.navigateBack({
                    delta: 1
                })
            }
        })
    }
})
